from futu import *
from module.common import Config
'''获取订单状态描述'''
def get_order_status_desc(type):
    if (type == OrderStatus.UNSUBMITTED):
        return '未提交'
    elif (type == OrderStatus.WAITING_SUBMIT):
        return '等待提交'
    elif (type == OrderStatus.SUBMITTING):
        return '提交中'
    elif (type == OrderStatus.SUBMIT_FAILED):
        return '提交失败，下单失败'
    elif (type == OrderStatus.SUBMITTED):
        return '等待成交'
    elif (type == OrderStatus.FILLED_PART):
        return '部分成交'
    elif (type == OrderStatus.FILLED_ALL):
        return '全部已成'
    elif (type == OrderStatus.CANCELLING_PART):
        return '正在撤单部分'
    elif (type == OrderStatus.CANCELLING_ALL):
        return '正在撤单全部'
    elif (type == OrderStatus.CANCELLED_PART):
        return '部分成交，剩余部分已撤单'
    elif (type == OrderStatus.CANCELLED_ALL):
        return '全部已撤单'
    elif (type == OrderStatus.FAILED):
        return '下单失败，服务拒绝'
    elif (type == OrderStatus.DISABLED):
        return '已失效'
    elif (type == OrderStatus.DELETED):
        return '已删除'
    else:
        return '未知'

'''获取交易类型描述'''
def get_trade_side_desc(type):
    if (type == TrdSide.BUY):
        return '买'
    elif (type == TrdSide.SELL):
        return '卖'
    elif (type == TrdSide.SELL_SHORT):
        return '卖空'
    elif (type == TrdSide.BUY_BACK):
        return '买回'
    else:
        return '未知'

'''获取code的类型1 2 3 4 5'''
def get_stock_type(code):
    if code in Config.IDX_list:  # 指数
        return Config.IDX_TYPE
    if code[0:2] == 'HK':  # 港股
        return Config.STOCK_TYPE_HK
    elif code[0:2] == 'US':  # 美股
        return Config.STOCK_TYPE_US
    elif len(code)>11:  # 期权=美股
        return Config.STOCK_TYPE_US
    elif code[0:2] == 'SZ' or code[0:2] == 'SH':  # A股
        return Config.STOCK_TYPE_CC
    else:  # 其他
        return Config.STOCK_TYPE_ERR